---
title: ODBCError Object (Excel)
keywords: vbaxl10.chm526072
f1_keywords:
- vbaxl10.chm526072
ms.prod: excel
api_name:
- Excel.ODBCError
ms.assetid: a256d466-7fa1-4b0f-fe01-c2640743e7e9
ms.date: 06/08/2017
---


# ODBCError Object (Excel)

Represents an ODBC error generated by the most recent ODBC query.


## Remarks

 The **ODBCError** object is a member of the **[ODBCErrors](odbcerrors-object-excel.md)** collection. If the specified ODBC query runs without error, the **ODBCErrors** collection is empty. The errors in the collection are indexed in the order in which they're generated by the ODBC data source.


## Example

Use  **[ODBCErrors](application-odbcerrors-property-excel.md)** ( _index_ ), where _index_ is the index number of the error, to return a single **ODBCError** object. The following example refreshes query table one and displays the first ODBC error that occurs.


```vb
With Worksheets(1).QueryTables(1) 
 .Refresh 
 If Application.ODBCErrors.Count > 0 Then 
 Set er = Application.ODBCErrors(1) 
 MsgBox "The following error occurred:" &; 
 er.ErrorString &; " : " &; er.SqlState 
 Else 
 MsgBox "Query complete: all records returned." 
 End If 
End With
```


## See also


#### Other resources



[Excel Object Model Reference](http://msdn.microsoft.com/library/11ea8598-8a20-92d5-f98b-0da04263bf2c%28Office.15%29.aspx)

